﻿using FireChat.Share.Web.Actions;
using Newtonsoft.Json;
using Newtonsoft.Json.Converters;

namespace FireChat.Share.Web.Package;


/// <summary>
/// 服务端发来的数据包， 客户端需要处理的包
/// </summary>
public class ServerPackage : IPackage, IResponse
{
    /// <summary>
    /// 一个空的数据包
    /// </summary>
    public static ServerPackage Empty { get; } = new()
    {
        IsSuccess = false,
        Message = "",
        ActionType = ClientActions.None
    };



    /// <summary>
    /// 客户端动作
    /// </summary>
    [JsonConverter(typeof(StringEnumConverter))]
    public virtual ClientActions ActionType { get; init; } = ClientActions.None;

    /// <summary>
    /// 数据包Id
    /// </summary>
    public string? Id { get; set; }

    /// <summary>
    /// 是否成功
    /// </summary>
    public required bool IsSuccess { get; init; }

    /// <summary>
    /// 附带消息
    /// </summary>
    public required string Message { get; init; }

    /// <summary>
    /// 响应的数据
    /// </summary>
    public object? Data { get; init; }
}